Skip to content

ENH: Add batteries-included index and DataFrame generators to tm #2446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

ENH: Add batteries-included index and DataFrame generators to tm #2446

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Dec 7, 2012

No description provided.

@ghost
Copy link
Author

ghost commented Dec 7, 2012

In [1]: from pandas.util.testing import makeCustomDataframe as mkdf
   ...:   mkdf(5,3)
Out[1]: 
C0      C_l0_g0 C_l0_g1 C_l0_g2
R0                             
R_l0_g0    R0C0    R0C1    R0C2
R_l0_g1    R1C0    R1C1    R1C2
R_l0_g2    R2C0    R2C1    R2C2
R_l0_g3    R3C0    R3C1    R3C2
R_l0_g4    R4C0    R4C1    R4C2

In [2]: from random import randint
In [2]: mkdf(5,3,data_gen_f=lambda r,c:randint(1,100))
Out[9]: 
C0       C_l0_g0  C_l0_g1  C_l0_g2
R0                                
R_l0_g0       38        9       64
R_l0_g1       42       45       94
R_l0_g2       15       94       16
R_l0_g3       80       39       33
R_l0_g4       94       30       63

In [3]: mkdf(5,3,c_idx_names=False,r_idx_names=False,
   ...:                              r_idx_type="dt",c_idx_type="u")
Out[3]: 
           ס4ןדםבדפגמ ץי4ףצ8י1נ2 3מקףיזשד4ר
2000-01-03       R0C0       R0C1       R0C2
2000-01-04       R1C0       R1C1       R1C2
2000-01-05       R2C0       R2C1       R2C2
2000-01-06       R3C0       R3C1       R3C2
2000-01-07       R4C0       R4C1       R4C2

In [4]: mkdf(5,3,r_idx_nlevels=2,r_ndupe_l=[2])
Out[4]: 
C0              C_l0_g0 C_l0_g1 C_l0_g2
R0      R1                             
R_l0_g0 R_l1_g0    R0C0    R0C1    R0C2
        R_l1_g1    R1C0    R1C1    R1C2
R_l0_g1 R_l1_g2    R2C0    R2C1    R2C2
        R_l1_g3    R3C0    R3C1    R3C2
R_l0_g2 R_l1_g4    R4C0    R4C1    R4C2

In [5]: mkdf(5,3,r_idx_nlevels=4,
   ...:                              r_idx_names=["FEE","FI","FO","FAM"],
   ...:                              c_idx_nlevels=2)
Out[5]: 
C0                              C_l0_g0 C_l0_g1 C_l0_g2
C1                              C_l1_g0 C_l1_g1 C_l1_g2
FEE     FI      FO      FAM                            
R_l0_g0 R_l1_g0 R_l2_g0 R_l3_g0    R0C0    R0C1    R0C2
R_l0_g1 R_l1_g1 R_l2_g1 R_l3_g1    R1C0    R1C1    R1C2
R_l0_g2 R_l1_g2 R_l2_g2 R_l3_g2    R2C0    R2C1    R2C2
R_l0_g3 R_l1_g3 R_l2_g3 R_l3_g3    R3C0    R3C1    R3C2
R_l0_g4 R_l1_g4 R_l2_g4 R_l3_g4    R4C0    R4C1    R4C2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant